import requests
import json
from datetime import datetime, timedelta


def getWindEdbRefreshData():
    # 获取当前时间
    now = datetime.now()
    # 获取当前小时
    formatted_date = now.strftime('%Y-%m-%d')
    current_date = datetime.now().date()
    date_seven_days_ago = current_date - timedelta(days=7)
    beginDate = date_seven_days_ago.strftime('%Y-%m-%d')
    endDate = current_date.strftime('%Y-%m-%d')
    url = 'http://10.111.22.165:8080/data_browser/indexDispatchRule/queryByIndexRefreshTime?dataSource=WIND&refreshFrequency=NATURAL_DAY'
    # 发送POST请求
    response = requests.get(url)
    data = json.loads(response.text)
    if data['success'] == True:
        edbCodes = data['data']
        print({'edbCodes': edbCodes, 'beginDate': beginDate, 'endDate': endDate})
    else:
        print({'edbCodes': None, 'beginDate': beginDate, 'endDate': endDate})


if __name__ == '__main__':
    getWindEdbRefreshData()
